# import time
#
# from selenium import webdriver
# from selenium.webdriver.chrome.service import Service
# from selenium.webdriver.common.by import By
# from webdriver_manager.chrome import ChromeDriverManager
# #自动化脚本
# #1.打开浏览器
# ChromeIns=ChromeDriverManager().install()
# driver=webdriver.Chrome(service=Service(ChromeIns))
# #2.输入百度网址
# time.sleep(2)
# driver.get("https://www.baidu.com")
# time.sleep(2)
# #3.找到百度搜索框，输入关键词
# driver.find_element(By.CSS_SELECTOR,"#kw").send_keys("雷军")
# time.sleep(2)
# #4.点击操作
# driver.find_element(By.CSS_SELECTOR,"#su").click()
# time.sleep(2)
# #5.关闭浏览器
# driver.quit()

import logging
import time

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager

# 增加 webdriver_manager 的日志级别
logging.getLogger('WDM').setLevel(logging.DEBUG) # 或者 logging.INFO

print("开始安装/获取 ChromeDriver...")
ChromeIns = ChromeDriverManager().install()
print(f"ChromeDriver 路径: {ChromeIns}")
print("正在启动 Chrome 浏览器...")
driver = webdriver.Chrome(service=Service(ChromeIns))
print("浏览器已启动。")

driver.get("https://www.baidu.com")
time.sleep(2)
driver.find_element(By.CSS_SELECTOR,"#kw").send_keys("123")
time.sleep(2)
driver.find_element(By.CSS_SELECTOR,"#su").click()
time.sleep(2)
driver.quit()